package com.leyou.page.controller;

import com.leyou.page.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class PageController {

    @Autowired
    private PageService pageService;
    @GetMapping("item/{id}.html")
    public String toItemPage(@PathVariable("id") Long id, Model model){

        Map<String, Object> attribuites = pageService.loadModel(id);
        model.addAllAttributes(attribuites);
        return "item";
    }
}
